package com.tengju.data.domain.model.template;

import lombok.Data;

import java.math.BigDecimal;

/**
 * 补贴模板系数
 * Created by develop at 2020/9/9.
 */
@Data
public class SubsidyTemplateRatio {

    /**
     * 业绩范围左边界
     */
    private long minPrice;

    /**
     * 业绩范围右边界
     */
    private long maxPrice;

    /**
     * 比率
     */
    private Double rebate;


    /**
     * 判断业绩是否符合次区间
     * @param achievement
     * @return
     */
    public boolean isMeet(BigDecimal achievement) {
        if (achievement == null) {
            return false;
        }
        if (minPrice == 0 && maxPrice == 0) {
            return true;
        }
        if (minPrice == 0) {
            return maxPrice > achievement.longValue();
        }
        if (maxPrice == 0) {
            return achievement.longValue() >= minPrice;
        }
        return achievement.longValue() >= minPrice && maxPrice > achievement.longValue();
    }

}
